package com.smart.controller;


import com.smart.entity.Result;
import com.smart.service.IEnvironmentDataService;
import com.smart.service.IEnvironmentThresholdsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 环境数据 前端控制器
 * </p>
 *
 * @author Cookies
 * @since 2024-05-19
 */
@RestController
@CrossOrigin
@RequestMapping("/environment-data")
@Api(tags = "环境数据相关接口")
public class EnvironmentDataController {
    @Autowired
    private IEnvironmentDataService environmentDataService;

    @GetMapping("/{current}/{size}/{type}")
    @ApiOperation(value = "分页获取环境数据", response = Result.class)
    public Result getEnvironmentDataByType(
            @PathVariable @ApiParam(name = "当前页", required = true) Integer current,
            @PathVariable @ApiParam(name = "每页条数", required = true) Integer size,
            @PathVariable @ApiParam(name = "环境类型", required = true) String type) {
        return Result.success(environmentDataService.getEnvironmentDataByType(current, size, type));
    }

    @GetMapping("/{device_id}")
    @ApiOperation(value = "根据设备ID获取环境数据", response = Result.class)
    public Result getEnvironmentDataById(
            @PathVariable @ApiParam(name = "设备ID", required = true) Integer device_id) {
        return Result.success(environmentDataService.getEnvironmentDataById(device_id));
    }
}
